package cn.chart.service.impl;

import cn.chart.domain.Users;
import cn.chart.service.UserService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService{

    public boolean checkUser(Users inUser) {
        Subject subject = SecurityUtils.getSubject();
        UsernamePasswordToken token = new UsernamePasswordToken
                (inUser.getUsername(),inUser.getPassword());
        try {
              subject.login(token);
            return true;
        }catch (AuthenticationException e){
            return false;
        }
    }
}
